1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.google.common.collect;
18
19 import com.google.common.annotations.GwtCompatible;
20
21 import java.io.Serializable;
22 import java.util.Arrays;
23
24
25
26
27
28
29
30
31
32 @GwtCompatible
33 class LegacyComparable implements Comparable, Serializable {
34 static final LegacyComparable X = new LegacyComparable("x");
35 static final LegacyComparable Y = new LegacyComparable("y");
36 static final LegacyComparable Z = new LegacyComparable("z");
37
38 static final Iterable<LegacyComparable> VALUES_FORWARD
39 = Arrays.asList(X, Y, Z);
40 static final Iterable<LegacyComparable> VALUES_BACKWARD
41 = Arrays.asList(Z, Y, X);
42
43 private final String value;
44
45 LegacyComparable(String value) {
46 this.value = value;
47 }
48
49 @Override
50 public int compareTo(Object object) {
51
52 LegacyComparable that = (LegacyComparable) object;
53 return this.value.compareTo(that.value);
54 }
55
56 @Override public boolean equals(Object object) {
57 if (object instanceof LegacyComparable) {
58 LegacyComparable that = (LegacyComparable) object;
59 return this.value.equals(that.value);
60 }
61 return false;
62 }
63
64 @Override public int hashCode() {
65 return value.hashCode();
66 }
67
68 private static final long serialVersionUID = 0;
69 }